package com.mooc.lib_common;

import android.app.Application;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @ClassName: AppGlobals$
 * @Description: java类作用描述
 * @Author: 魏靳元
 * @CreateDate: 2022/8/13 16:13
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class MyApplication {
    private static Application sApplication;
    public static Application getsApplication(){
        if(sApplication==null){
            try {
                Method method = Class.forName("android.app.ActivityThread").getDeclaredMethod("currentApplication");
                sApplication = (Application) method.invoke(null, null);
            } catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
        return sApplication;
    }
} 
